package org.kl.bf.utils;

import java.util.HashMap;
import java.util.Map;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Workbook;

/**
 * EXCEL单元格样式构造器
 * @author QJ
 * @date 2015年4月1日
 */
public class StyleBuilder {
	 
	private  Map<Integer,Integer> styleMap = new HashMap<Integer, Integer>();
	public static final int BG_COLOR=1;
	
	public  CellStyle buildCellStyle(Workbook wb){
		CellStyle cellStyle = wb.createCellStyle();
		for(Integer key : styleMap.keySet()){
			switch (key) {
			case BG_COLOR:
				cellStyle.setFillForegroundColor(styleMap.get(key).shortValue());
				cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
				break;
			default:
				break;
			}
		}
		return cellStyle;
	}
	
	public StyleBuilder build(int key,short value){
		styleMap.put(new Integer(key), new Integer(value));
		return this;
	}
}
